from __future__ import annotations
from abc import ABC, abstractmethod
from Strategy.fly import *
from Strategy.quack import *


class Duck(ABC):
    def __init__(self, flyBehavior: FlyBehavior, quackBehavior: QuackBehavior) -> None:
        self._flyBehavior = flyBehavior
        self._quackBehavior = quackBehavior

    @abstractmethod
    def perform(self) -> None:
        pass

    def performFly(self) -> None:
        return self._flyBehavior.fly()

    def performQuack(self) -> None:
        return self._quackBehavior.quack()

    @property
    def flyBehavior(self) -> FlyBehavior:
        return self._flyBehavior

    @property
    def quackBehavior(self) -> QuackBehavior:
        return self._quackBehavior

    @flyBehavior.setter
    def flyBehavior(self, fly: FlyBehavior) -> None:
        self._flyBehavior = fly

    @quackBehavior.setter
    def quackBehavior(self, quack: QuackBehavior) -> None:
        self._quackBehavior = quack

    def swim(self) -> None:
        print("All ducks float, even decoys")


class ModelDuck(Duck):
    def __init__(self, flyBehavior: FlyNoWay, quackBehavior: Quack) -> None:
        super().__init__(flyBehavior, quackBehavior)
        # 下面的初始化方法，并不能继承父类的属性
        # _flyBehavior = flyBehavior
        # _quackBehavior = quackBehavior

    def perform(self) -> None:
        print("I'm a model duck")


class MallardDuck(Duck):
    def __int__(self, flyBehavior: FlyWithWings, quackBehavior: Quack) -> None:
        super().__init__(flyBehavior, quackBehavior)

    def perform(self) -> None:
        print("I'm a real Mallard duck")






